package net.oschina.dajiangnan.wx.constants;

import javax.servlet.ServletConfig;

public class Config {

	public static String appid;
	public static String appSecret;
	public static String token;
	public static String mch_id;
	public static String apikey;
	public static String pkcs12FileName;
	public static String pics_pass;

	/**
	 * 
	 * @param appid,公众号APPID ,【 https://mp.weixin.qq.com/  --> 开发者中心 --> 配置项  -->  开发者ID  -->  appid 】
	 * @param appSecret,appSecret ,【 https://mp.weixin.qq.com/  --> 开发者中心 --> 配置项  -->  开发者ID  -->  AppSecret 】
	 * @param token,Token令牌 , 【 https://mp.weixin.qq.com/  --> 开发者中心 --> 配置项  -->  服务器配置 -->  Token 】
	 * @param mch_id,微信支付商户号, 【https://pay.weixin.qq.com/index.php/account  -->  账户设置  --> 账户信息】
	 * @param apikey,32位api密码, 【https://pay.weixin.qq.com/index.php/account  -->  账户设置  --> API安全  -->  秘钥设置】
	 * @param pkcs12FileName,https证书文件,开通支付的时候由微信发给商户
	 * @param pics_pass,https证书相关密码,开通支付的时候由微信发给商户
	 */
	public static void init(String appid,String appSecret,String token,String mch_id,
	        String apikey,String pkcs12FileName,String pics_pass) {
	    Config.appid = appid;
	    Config.appSecret = appSecret;
	    Config.token = token;
	    Config.mch_id = mch_id;
	    Config.apikey = apikey;
	    Config.pkcs12FileName = pkcs12FileName;
	    Config.pics_pass = pics_pass;
	}
	public static void init(ServletConfig config) throws Exception {
		if (appid == null) {
			appid = config.getInitParameter("appid");
		}
		if (appSecret == null) {
			appSecret = config.getInitParameter("appSecret");
		}
		if (token == null) {
			token = config.getInitParameter("token");
		}
		if (mch_id == null) {
			mch_id = config.getInitParameter("mch_id");
		}
		if (apikey == null) {
			apikey = config.getInitParameter("apikey");
		}

		if (pkcs12FileName == null) {
			pkcs12FileName = config.getInitParameter("pkcs12FileName");
		}
		
		if (pics_pass == null) {
			pics_pass = config.getInitParameter("pics_pass");
		}

	}

}
